package io.itit.ecp.admin.server.service.impl;

import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
import io.itit.ecp.admin.server.entity.CarbonSinkFactorEntity;
import io.itit.ecp.admin.server.mapper.CarbonSinkFactorMapper;
import io.itit.ecp.admin.server.service.ICarbonSinkDataService;
import io.itit.ecp.admin.server.service.ICarbonSinkFactorService;
import io.itit.ecp.admin.server.service.IEnergyDataService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 *
 * @Author：Roy
 * @Description：碳汇因子服务实现类
 * @Date：Create by 2023-11-23 16:12:43
 */
@Service
public class CarbonSinkFactorServiceImpl extends JoinServiceImpl<CarbonSinkFactorMapper, CarbonSinkFactorEntity> implements ICarbonSinkFactorService {

    @Resource
    private ICarbonSinkDataService carbonSinkDataService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateCarbonSinkFactor(CarbonSinkFactorEntity entity) {
        if(updateById(entity)){
            // 根据植被类型及日期更新数据管理模块中相关数据
            carbonSinkDataService.causeFactorUpdate(entity.getType(),entity.getSolidifyDate(),entity.getFactor());
            return true;
        }
        return false;
    }
}
